package com.gl.codewar.template;

public class Palindrome {

	public static int reverseAdd(int i) {
		int total = i;
		while (pal(total)){
			total += reverse(String.valueOf(total));
		}
			
		
		return total;
	}
	
	public static int reverse(String value) {
		StringBuffer buffer = new StringBuffer();
		for (int aux= 0;aux < value.length();aux++){
			buffer.append(String.valueOf( value.charAt(aux) ));
		}
		buffer.reverse();
		return Integer.valueOf(buffer.toString()).intValue();
	}

	public static boolean pal (int total) {
		String aux = String.valueOf(total);
		StringBuilder sb = new StringBuilder(aux).reverse();
		if (sb.toString().equals(aux)) {
			return false;
		}
		return true;
	}
}
